var appInstance = getApp(), dataApi = require("../../provider/dataApi.js");

require("../../provider/pipe.js");

Page({
    data: {
        statusBarHeight: "",
        titleBarHeight: "",
        phoneNumber: "",
        contentValue: ""
    },
    onLoad: function(options) {
        options = appInstance.globalData.id, this.setData({
            statusBarHeight: getApp().globalData.statusBarHeight,
            titleBarHeight: getApp().globalData.titleBarHeight,
            id: options
        });
    },
    goBack: function() {
        wx.navigateBack({
            delta: 1
        });
    },
    getPhone: function(event) {
        this.setData({
            phoneNumber: event.detail.value
        });
    },
    getCon: function(event) {
        this.setData({
            contentValue: event.detail.value
        });
    },
    goSubmit: function() {
      if (this.data.phoneNumber && this.data.contentValue) {
        // 用户已输入手机号和反馈内容
        dataApi.feedback({
            tid: this.data.id,
            uid: wx.getStorageSync("uid"),
            relation: this.data.phoneNumber,
            content: this.data.contentValue
        }).then(function (response) {
            wx.showModal({
                title: "提示",
                content: "反馈已提交~",
                showCancel: !1,
                success: function (response) {}
            });
            wx.navigateBack({
                delta: 1
            });
        }).catch(function (error) {
            console.log(error);
        });
    } else {
        if (!this.data.phoneNumber) {
            // 用户未输入手机号
            wx.showToast({
                icon: "none",
                title: "请输入手机号~"
            });
        } else {
            // 用户未输入反馈内容
            wx.showToast({
                icon: "none",
                title: "请输入内容~"
            });
        }
    }
    }
});